<?php
/**
 * @Copyright Copyright (C) 2009- 2011... Webit Solution
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	uninstall.wrecruit.php
 ^ 
 */

defined ('_JEXEC') or die ('Restricted access');

function com_uninstall()
{
	global $mainframe;
	$db = &JFactory::getDBO();
	
	$query = "SELECT * FROM ".$db->nameQuote('#__wrecruit_config')." WHERE configname = 'backuponuninstall'";
	$db->setQuery($query);
	//echo '<br>SQL '.$query;
	$backup = $db->loadObject();
	
	if ($backup->configvalue == '1'){
		$returnvalue = take_back_up();
		if ($returnvalue == 1) echo '<p>Uninstall for WRecruit\'s WRecruit Component successful.</p>';
	}else{
		echo '<p>Uninstall for WRecruit\'s WRecruit Component successful.</p>';
		$returnvalue = 1;
	}	

	return $returnvalue;
	
}

function take_back_up()
{
	$str=JPATH_BASE;
	$base = substr($str, 0,strlen($str)-14); //remove administrator
	$path =$base.'/components/com_wrecruit/data/';
	$newpath =$base.'/components/wrecruit_data_bak';
/*
	if (file_exists($path)){
		full_copy($path, $newpath);
		echo '<br>Backup Resume directory : '.$newpath;
	}
*/
	$db = &JFactory::getDBO();

	$agesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_ages_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_ages_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_ages').'';
	$careerlevelsquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_careerlevels_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_careerlevels_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_careerlevels').'';
	$experiencesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_experiences_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_experiences_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_experiences').'';
	$departmentsquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_departments_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_departments_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_departments').'';
	$shortlistcandidatesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_shortlistcandidates_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_shortlistcandidates_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_shortlistcandidates').'';

	$employerpackagesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_employerpackages_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_employerpackages_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_employerpackages').'';
	$employerpaymenthistoryquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_employerpaymenthistory_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_employerpaymenthistory_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_employerpaymenthistory').'';
	$jobseekerpackagesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobseekerpackages_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobseekerpackages_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobseekerpackages').'';
	$jobseekerpaymenthistoryquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobseekerpaymenthistory_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobseekerpaymenthistory_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobseekerpaymenthistory').'';
	$goldcompaniesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_goldcompanies_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_goldcompanies_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_goldcompanies').'';

	$goldjobsquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_goldjobs_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_goldjobs_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_goldjobs').'';
	$goldresumesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_goldresumes_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_goldresumes_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_goldresumes').'';
	$featuredcompaniesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_featuredcompanies_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_featuredcompanies_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_featuredcompanies').'';
	$featuredjobsquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_featuredjobs_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_featuredjobs_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_featuredjobs').'';
	$featuredresumesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_featuredresumes_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_featuredresumes_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_featuredresumes').'';
	$salaryrangetypesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_salaryrangetypes_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_salaryrangetypes_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_salaryrangetypes').'';

	$configquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_config_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_config_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_config').''; 
	$catquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_categories_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_categories_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_categories').''; 
	$salaryquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_salaryrange_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_salaryrange_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_salaryrange').''; 
	$jobquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobs_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobs_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobs').''; 
	$jobapplyquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobapply_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobapply_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobapply').''; 
	//$joballowquery = getSQLJOBALLOWBackup();
	$eaquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_resume_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_resume_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_resume').''; 

	$countriesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_countries_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_countries_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_countries').''; 
	$statesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_states_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_states_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_states').''; 
	$countiesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_counties_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_counties_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_counties').'';
	$citiesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_cities_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_cities_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_cities');
	$zipsquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_zips_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_zips_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_zips');




	$companiesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_companies_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_companies_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_companies');
	$jobsearchesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobsearches_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobsearches_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobsearches');
	$jobstatusquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobstatus_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobstatus_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobstatus');
	$jobtypesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobtypes_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobtypes_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobtypes');
	$shiftsquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_shifts_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_shifts_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_shifts');
	

	$coverlettersquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_coverletters_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_coverletters_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_coverletters');
	$emailtemplatesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_emailtemplates_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_emailtemplates_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_emailtemplates');
	$fieldorderingquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_fieldsordering_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_fieldsordering_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_fieldsordering');
	$filtersquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_filters_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_filters_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_filters');
	$educationquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_heighesteducation_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_heighesteducation_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_heighesteducation');


	$resumesearchquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_resumesearches_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_resumesearches_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_resumesearches');

	$rolesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_roles_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_roles_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_roles');
	$userfieldsquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_userfields_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_userfields_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_userfields');
	$userfieldvaluequery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_userfieldvalues_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_userfieldvalues_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_userfieldvalues');
	$userfielddataquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_userfield_data_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_userfield_data_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_userfield_data');
	$userrolesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_userroles_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_userroles_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_userroles');

	$folderresumesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_folderresumes_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_folderresumes_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_folderresumes');
	$foldersquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_folders_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_folders_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_folders');
	$jobalertsettingquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_jobalertsetting_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_jobalertsetting_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_jobalertsetting');
	$messagesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_messages_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_messages_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_messages');
	$resumeratingquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_resumerating_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_resumerating_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_resumerating');
	$subcategoriesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_subcategories_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_subcategories_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_subcategories');

	$currenciesquery = 'DROP TABLE IF EXISTS '.$db->nameQuote('#__wrecruit_currencies_bak').'; CREATE TABLE '.$db->nameQuote('#__wrecruit_currencies_bak').' SELECT * FROM '.$db->nameQuote('#__wrecruit_currencies');
	
	$db->setQuery($agesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Agess backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Ages.</font>');

	$db->setQuery($careerlevelsquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Career Levels backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Career Levels.</font>');

	$db->setQuery($experiencesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Experiences backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Experiences.</font>');

	$db->setQuery($departmentsquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Departments backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Departments.</font>');

	$db->setQuery($shortlistcandidatesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Short List Candidates backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Short List Candidates.</font>');

	$db->setQuery($employerpackagesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Employer Packages backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Employer Packages.</font>');

        $db->setQuery($employerpaymenthistoryquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Employer Payment History backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Employer Payment History.</font>');

        $db->setQuery($jobseekerpackagesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Job Seeker Packages backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Job Seeker Packages.</font>');

        $db->setQuery($jobseekerpaymenthistoryquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Job Seeker Payment History backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Job Seeker Payment History.</font>');

        $db->setQuery($goldcompaniesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Gold Companies backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Gold Companies.</font>');

        $db->setQuery($goldjobsquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Gold Jobs backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Gold Jobs.</font>');

        $db->setQuery($goldresumesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Gold Resumes backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Gold Resumes.</font>');

        $db->setQuery($featuredcompaniesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Featured Companies backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Featured Companies.</font>');

        $db->setQuery($featuredjobsquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Featured Jobs backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Featured Jobs.</font>');

        $db->setQuery($featuredresumesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Featured Resumes backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Featured Resumes.</font>');

        $db->setQuery($salaryrangetypesquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Salary Range Types backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Salary Range Types.</font>');

        $db->setQuery($configquery);
	if ( $result = $db->queryBatch()) echo JText::_('<br>Configurations backup successful!');
	else echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Configurations.</font>');

	$db->setQuery($catquery);
	if ( $result = $db->queryBatch())	echo JText::_('<br>Categories Data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('<br>Error occurred while attempting to backup up Categories data.</font><br>');

	$db->setQuery($salaryquery);
	if ( $result = $db->queryBatch())	echo JText::_('Salary Range Data backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Salary Range data.</font><br>');

	$db->setQuery($jobquery);
	if ( $result = $db->queryBatch())	echo JText::_('Job Data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Job data.</font><br>');

	$db->setQuery($jobapplyquery);
	if ( $result = $db->queryBatch())	echo JText::_('Job Apply Data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Job Apply data.</font><br>');
/*
	$db->setQuery($joballowquery);
	if ( $result = $db->queryBatch())	echo JText::_('User Allow Data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up User Allow data.</font><br>');
*/
	$db->setQuery($eaquery);
	if ( $result = $db->queryBatch())	echo JText::_('Resume data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Resume data.</font><br>');

	$db->setQuery($companiesquery);
	if ( $result = $db->queryBatch()) echo JText::_('Companies backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Companies.</font><br>');

	$db->setQuery($jobsearchesquery);
	if ( $result = $db->queryBatch()) echo JText::_('Job Searches backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Job Searches.</font><br>');

	$db->setQuery($jobstatusquery);
	if ( $result = $db->queryBatch()) echo JText::_('Job Status backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Job Status.</font><br>');

	$db->setQuery($jobtypesquery);
	if ( $result = $db->queryBatch()) echo JText::_('Job Types backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Job Types.</font><br>');

	$db->setQuery($shiftsquery);
	if ( $result = $db->queryBatch()) echo JText::_('Job Shifts backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Job Shifts.</font><br>');

	$db->setQuery($coverlettersquery);
	if ( $result = $db->queryBatch()) echo JText::_('Cover Letters backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Cover Letters.</font><br>');

	$db->setQuery($emailtemplatesquery);
	if ( $result = $db->queryBatch()) echo JText::_('Email Templates backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Email Templates.</font><br>');

	$db->setQuery($fieldorderingquery);
	if ( $result = $db->queryBatch()) echo JText::_('Field Ordering backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Field Ordering.</font><br>');

	$db->setQuery($filtersquery);
	if ( $result = $db->queryBatch()) echo JText::_('Filters backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Filters.</font><br>');

	$db->setQuery($educationquery);
	if ( $result = $db->queryBatch()) echo JText::_('Heighest Education backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Heighest Education.</font><br>');
	
	$db->setQuery($resumesearchquery);
	if ( $result = $db->queryBatch()) echo JText::_('Resume Searches backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Resume Searches.</font><br>');

	$db->setQuery($rolesquery);
	if ( $result = $db->queryBatch()) echo JText::_('Roles backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Roles.</font><br>');

	$db->setQuery($userfieldsquery);
	if ( $result = $db->queryBatch()) echo JText::_('User Fields backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up User Fileds.</font><br>');

	$db->setQuery($userfieldvaluequery);
	if ( $result = $db->queryBatch()) echo JText::_('User Field Values backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up User Field Values.</font><br>');

	$db->setQuery($userfielddataquery);
	if ( $result = $db->queryBatch()) echo JText::_('User Field Data backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up User Field Data.</font><br>');

	$db->setQuery($userrolesquery);
	if ( $result = $db->queryBatch()) echo JText::_('User Roles backup successful!<br>');
	else echo "<font color='red'>".JText::_('Error occurred while attempting to backup up User Roles.</font><br>');

	
	$db->setQuery($countriesquery);
	if ( $result = $db->queryBatch())	echo JText::_('Countries data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Countries data.</font><br>');
	
	$db->setQuery($statesquery);
	if ( $result = $db->queryBatch())	echo JText::_('States data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up States data.</font><br>');

	$db->setQuery($countiesquery);
	if ( $result = $db->queryBatch())	echo JText::_('Counties data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Counties data.</font><br>');

	$db->setQuery($citiesquery);
	if ( $result = $db->queryBatch())	echo JText::_('Cities data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Cities data.</font><br>');

	$db->setQuery($zipsquery);
	if ( $result = $db->queryBatch())	echo JText::_('Zips data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Zips data.</font><br>');

	$db->setQuery($folderresumesquery);
	if ( $result = $db->queryBatch())	echo JText::_('Folder Resume data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Folder Resume data.</font><br>');
	
	$db->setQuery($foldersquery);
	if ( $result = $db->queryBatch())	echo JText::_('Folders data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Folders data.</font><br>');
	
	$db->setQuery($jobalertsettingquery);
	if ( $result = $db->queryBatch())	echo JText::_('Job Alert Settings data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Job Alert Setting data.</font><br>');
	
	$db->setQuery($messagesquery);
	if ( $result = $db->queryBatch())	echo JText::_('Messages data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Messages data.</font><br>');
	
	$db->setQuery($resumeratingquery);
	if ( $result = $db->queryBatch())	echo JText::_('Resume Rating data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Resume Rating data.</font><br>');
	
	$db->setQuery($subcategoriesquery);
	if ( $result = $db->queryBatch())	echo JText::_('Sub Categories data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Sub Categories data.</font><br>');

	$db->setQuery($currenciesquery);
	if ( $result = $db->queryBatch())	echo JText::_('Currencies data backup successful!<br>');
	else	echo "<font color='red'>".JText::_('Error occurred while attempting to backup up Currencies data.</font><br>');

	return true;
}

function full_copy( $source, $target ) {
	if ( is_dir( $source ) ) {
		@mkdir( $target );
		$d = dir( $source );
		while ( FALSE !== ( $entry = $d->read() ) ) {
			if ( $entry == '.' || $entry == '..' ) {
				continue;
			}
			$Entry = $source . '/' . $entry; 
			if ( is_dir( $Entry ) ) {
				full_copy( $Entry, $target . '/' . $entry );
				continue;
			}
			copy( $Entry, $target . '/' . $entry );
		}
 
		$d->close();
	}else {
		copy( $source, $target );
	}
}
 
?>
